﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace praticeWinforms
{
    public class DBHelper
    {
        private static readonly string conString = "server=.;database=School;uid=sa;pwd=lsy6796159..";

        public static DataTable GetdataTable(string sql)
        {
            SqlConnection sqlconn = new SqlConnection(conString);
            sqlconn.Open();
            SqlDataAdapter sqldar = new SqlDataAdapter(sql, sqlconn);
            DataTable dt = new DataTable();
            sqldar.Fill(dt);
            return dt;
        }
        public static int AddUpdateordelete(string sql)
        {
            SqlConnection sqlconn = new SqlConnection(conString);
            sqlconn.Open();
            SqlCommand sqlcmd = new SqlCommand(sql, sqlconn);
            return sqlcmd.ExecuteNonQuery();

        }
    }
}
